Column

Chart A

Column

Chart B

Chart C

---
title: "dashboard"
output: 
  flexdashboard::flex_dashboard:
    orientation: columns
    vertical_layout: fill
    source: embed
---

```{r setup, include=FALSE}
library(tidyverse)
library(p8105.datasets)
library(plotly)
data("ny_noaa")

ny_noaa = ny_noaa %>%
  na.omit()

library(flexdashboard)
```

Column {data-width=650}
-----------------------------------------------------------------------

### Chart A

```{r}
ny_noaa %>%
  filter(id == "USC00300023" | id == "USC00300028" | id == "USC00300055" | id == "USC00300063" | id == "USC00300085") %>%
  sample_n(5000) %>%
  mutate(text_label = str_c("date:", date)) %>% 
  plot_ly(x = ~snow, y = ~snwd, color = ~id, 
          type = "scatter", mode = "markers", text = ~text_label, alpha = 0.5) %>%
  layout(title = "Snow depth vs. snow fall for several weather stations")

```

Column {data-width=350}
-----------------------------------------------------------------------

### Chart B

```{r}
ny_noaa %>% 
  filter(id == "USC00300023" | id == "USC00300028" | id == "USC00300055" | id == "USC00300063" | id == "USC00300085") %>%
  plot_ly(y = ~tmax, color = ~id, type = "box", colors = "viridis") %>% layout(title = "The boxplot of max temperature for \n several weather stations")


```

### Chart C

```{r}
ny_noaa %>%
  sample_n(2000) %>%
  count(id) %>%
  mutate(id = fct_reorder(id, n)) %>% 
  plot_ly(x = ~id, y = ~n, color = ~id, type = "bar", colors = "viridis") %>%
  layout(title = "The number of observations for \n
         several weather stations")

```